/**
 * @(#)ApkConfigController.java 2017年03月1日
 * Copyright(C) 2017 ZHEXIN IT CO.,LTD. All rights reserved.
 */
package org.jsbd.boss.action;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.domian.LogStatisticsActionBean;
import org.jsbd.boss.service.ILogStatisticsActionService;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.common.ResponseMapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/logStatisticsAction")
public class LogStatisticsActionController{

	private static final Logger LOGGER=LoggerFactory.getLogger(LogStatisticsActionController.class);
	
	@Autowired
	private ILogStatisticsActionService logStatisticsActionService;

	/**
	 * 列表页面
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "listModel")
	public String showLogStatisticsActionList(Model model) throws Exception {
		return "/logStatisticsAction/logStatisticsActionList";
	}

	@RequestMapping(value = "saveLogStatisticsAction")
	@ResponseBody
	public Object saveLogStatisticsAction(LogStatisticsActionBean logStatisticsAction){
		logStatisticsAction.setStatus(0);
		logStatisticsActionService.saveLogStatisticsAction(logStatisticsAction);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "updateLogStatisticsAction")
	@ResponseBody
	public Object updateLogStatisticsAction(LogStatisticsActionBean logStatisticsAction){
		if (logStatisticsAction.getId() == null) {
			return ResponseMapUtils.responseFail("参数缺失，请确认参数再提交");
		}
		
		LogStatisticsActionBean condition=new LogStatisticsActionBean();
		condition.setId(logStatisticsAction.getId());
		LogStatisticsActionBean temp=logStatisticsActionService.getLogStatisticsAction(condition);
		if(temp==null){
			return ResponseMapUtils.responseFail("记录未找到,请重试");
		}
		
		logStatisticsActionService.updateLogStatisticsAction(logStatisticsAction);
		return ResponseMapUtils.responseSuccess();
	}

	@RequestMapping(value = "getLogStatisticsAction")
	@ResponseBody
	public LogStatisticsActionBean getLogStatisticsAction(LogStatisticsActionBean logStatisticsAction) throws Exception {
		return logStatisticsActionService.getLogStatisticsAction(logStatisticsAction);
	}

	@RequestMapping(value = "getLogStatisticsActionList")
	@ResponseBody
	public List<LogStatisticsActionBean> getLogStatisticsActionList(LogStatisticsActionBean logStatisticsAction) throws Exception {
		return logStatisticsActionService.getLogStatisticsActionList(logStatisticsAction);
	}

	@RequestMapping(value = "getLogStatisticsActionListPage")
	@ResponseBody
	public Map<String, Object> getLogStatisticsActionListPage(DataGridModel page, LogStatisticsActionBean logStatisticsAction) throws Exception {
		return logStatisticsActionService.getLogStatisticsActionListPage(page, logStatisticsAction);
	}
	
	@RequestMapping(value = "updateStatus")
	@ResponseBody
	public Map<String, Object> getLogStatisticsActionListPage(LogStatisticsActionBean logStatisticsAction) throws Exception {
		LogStatisticsActionBean condition=new LogStatisticsActionBean();
		condition.setId(logStatisticsAction.getId());
		LogStatisticsActionBean temp=logStatisticsActionService.getLogStatisticsAction(condition);
		if(temp==null){
			return ResponseMapUtils.responseFail("记录未找到,请重试");
		}
		temp.setStatus(logStatisticsAction.getStatus());
		logStatisticsActionService.updateStatus(temp);
		return ResponseMapUtils.responseSuccess();
	}
	
	@RequestMapping(value = "deleteLogStatisticsAction")
	@ResponseBody
	public Map<String, Object> deleteLogStatisticsAction(LogStatisticsActionBean logStatisticsAction) throws Exception {
		logStatisticsActionService.deleteLogStatisticsAction(logStatisticsAction);
		return ResponseMapUtils.responseSuccess();
	}
	

}
